package cn.com.shaom.learning.sb.data.mongodb;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Collection;
import java.util.LinkedHashSet;

/**
 * ClassName: User
 * Description: Mongodb 的一个 Document 实体
 * Date: 2017/12/27 10:23 【需求编号】
 *
 * @author Shaom
 * @version V1.0.0
 */
@Document
public class User {

    @Id
    private String id;
    private String name;
    private Integer age;

    // 数组的形式进行保存
    @Field("locs")
    private Collection<Location> locations = new LinkedHashSet<Location>();

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Collection<Location> getLocations() {
        return locations;
    }

    public void setLocations(Collection<Location> locations) {
        this.locations = locations;
    }
}
